#pragma once

#include <string>
#include <iostream>
std::string OP = "+-*%/";

enum
{
    Div_zore = 1,
    Mod_zore = 2,
    No_op = 3,
};

class Task
{
public:
    Task()
    {

    }

    Task(int a, int b, char c)
        : _data1(a)
        , _data2(b)
        , _op(c)
        {}

    void run()
    {
        switch (_op)
        {
        case '+':
            _result = _data1 + _data2;
            break;
        case '-':
            _result = _data1 - _data2;
            break;
        case '*':
            _result = _data1 * _data2;
            break;
        case '%':
            {
                if(_data2 == 0)
                {
                    _exitcode = 2;
                    break;
                }
                _result = _data1 % _data2;
                break;
            }
            
        case '/':
            {
                if(_data2 == 0)
                {
                    _exitcode = 1;
                    break;
                }
                _result = _data1 / _data2;
                break;
            }
        default:
            _exitcode = 3;
            break;
        }

    }

    std::string getTask()
    {
        std::string ret = std::to_string(_data1) + " " + _op + " " + std::to_string(_data2) +  " = ? " ;

        return ret;
    }

    std::string finishTask()
    {
        std::string ret = " 完成一个任务 :" + std::to_string(_data1) + " " + _op + " " + std::to_string(_data2) +  " = "  + std::to_string(_result);
        ret += " [exitcode:" + std::to_string(_exitcode) + "]";

        return ret;
    }

private:
    int _data1 = 0;
    int _data2 = 0;
    char _op;
    int _result = 0;
    int _exitcode = 0;
};